import json
import os
import re

from htmlfile.TxtParse.PaperParse import PaperParse
from htmlfile.htmlmodel import *
from bottle import template

if __name__ == '__main__':
    path = '''C:\\Users\\bajie\Desktop\\nov\\'''
    with open('catelague.json', 'r', encoding="utf-8") as f:
        catalogues = json.load(f)
    category = "short article"
    to_path = "D:\\NiceNovel\\App_ReadNovel\\templates\\"
    id = "4601"
    catalogue = catalogues[id]
    with open(path + category + '\\' + id + '.txt', 'r', encoding='utf-8') as f:
        novels = f.readlines()
        init = PaperParse(novels)
        init.second()
        init.parseall()
        novel = init.getcontent()
        print("成功读取" + id + ".txt文件")
        html = template(html, novel=novel, catalogue=catalogue)
        with open(to_path + id + ".html", 'wb') as f:
            f.write(html.encode('utf-8'))
            print("成功生成" + id + ".html文件")







